feat: Adaptive MCTS with batch parallel simulation#1
Closed
CyberGhost007 wants to merge 1 commit intomainfrom
Closed
feat: Adaptive MCTS with batch parallel simulation#1CyberGhost007 wants to merge 1 commit intomainfrom
CyberGhost007 wants to merge 1 commit intomainfrom
Conversation
- Dynamic iteration bounds (8-50 for Phase 2, 5-30 for Phase 1) instead of fixed counts, saving LLM calls on easy queries - Multi-signal convergence detection: top-k stability, reward variance stability, and confidence threshold (any triggers stop) - Branch pruning: marks consistently low-scoring subtrees as pruned, skipping them in select/expand to avoid wasting LLM calls - Exploration constant decay (linear/cosine) from 2.0 to 0.5 over search lifetime — explore broadly first, exploit later - Batch simulation with virtual loss trick (AlphaGo-style): selects K nodes per iteration using virtual visits for diversity, fires K LLM calls in parallel, then backpropagates real rewards — cuts wall-clock time by ~4x without changing search quality - SearchStats dataclass for transparent reporting of convergence, pruning, and coverage metrics in all results - Full backward compat: adaptive=False falls back to exact prior behavior (fixed iterations, static C, original early stopping) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MCTS_ADAPTIVE=falsefalls back to exact prior behavior: fixed iteration counts, static exploration constant, original early stopping heuristic.Files changed
treerag/config.pytreerag/mcts.py_get_exploration_constant,_check_convergence,_prune_branches,_apply_virtual_loss,_remove_virtual_loss,_simulate_batch, updatedsearch_document/search_metaloopstreerag/models.pyprunedflag on TreeNode/FolderDocEntry,SearchStatsdataclass, stats fields on QueryResulttreerag/pipeline.py.env.exampletests/test_config.pytests/test_models.pyTest plan
pytest tests/— 25 tests passMCTS_ADAPTIVE=true(default) — verify console shows convergence info and reduced iteration countsMCTS_ADAPTIVE=false— verify identical behavior to previous versionMCTS_SIMULATION_BATCH_SIZE=1degrades gracefully to sequential mode